package com.jt.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.ListOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

//@Component
@Repository
public class SecondKillQueue {
      @Autowired
     private StringRedisTemplate stringRedisTemplate;//使用redis模板
      @Resource(name = "redisTemplate")
      private  ListOperations<String,String> lo;//使用list集合操作
      //入队【带参】
      public void inqueue(String msg){
        //  ListOperations<String, String> lo = stringRedisTemplate.opsForList();
          lo.leftPush("killQueue", msg);
      }
      //出队【无参】
     public String dequeue(){
        // ListOperations<String, String> lo = stringRedisTemplate.opsForList();
         return lo.rightPop("killQueue");
     }
}
